package Logicamente;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Image;

import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import javax.swing.ImageIcon;

import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.SwingConstants;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class DialogoRedSocial extends JDialog {

	private String imagen;
	private DialogoCompartir dialogoPadre;
	private final JPanel contentPane;
	
	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public DialogoRedSocial(String s,DialogoCompartir dc) {
		this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		imagen = s;
		dialogoPadre = dc;
		setBounds(100, 100, 450, 300);
		contentPane = new JPanelConFondo("/Imagenes/fondo.jpg");
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		JPanel panel_superior = new JPanelConFondo("/Imagenes/fondo_t.png");
		panel_superior.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(panel_superior, BorderLayout.CENTER);
		panel_superior.setLayout(new GridLayout(1, 0, 0, 0));
		{
			JLabel lblImagen = new JLabel("");
			lblImagen.setHorizontalAlignment(SwingConstants.CENTER);
			panel_superior.add(lblImagen);
			lblImagen.setIcon(new ImageIcon(VentanaFinDeJuego.class.getResource(s)));
			this.setSize(lblImagen.getIcon().getIconWidth(), (100+lblImagen.getIcon().getIconHeight()));
			
		}
		{
			JPanel buttonPane = new JPanelConFondo("/Imagenes/fondo_t.png");
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton cancelButton = new JButton("");
				cancelButton.setIcon(new ImageIcon(DialogoRedSocial.class.getResource("/Imagenes/boton_volver_f.png")));
				cancelButton.setActionCommand("Cancel");
				cancelButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						cancelButtonActionPerformed(evt);
					}
				});
				buttonPane.add(cancelButton);
			}
		}
	}
	
	@SuppressWarnings("deprecation")
	protected void cancelButtonActionPerformed(ActionEvent evt) {
		this.setVisible(false);
		this.hide();
		dialogoPadre.activar(true);
	}
}
